#ifndef _M_LOG_H
#define _M_LOG_H
#include <stdio.h>
#include <time.h>

#define INF 0
#define BEBUG 1
#define ERROR 2
#define DEFAULT_LOG_LEVEL INF

#define LOG(level, format, ...)                             \
    do                                                      \
    {                                                       \
        if (DEFAULT_LOG_LEVEL > level)                      \
            break;                                          \
        time_t t = time(nullptr);                           \
        struct tm *lt = localtime(&t);                      \
        char buffer[32] = {0};                              \
        strftime(buffer, 31, "%H:%M:%S", lt);               \
        fprintf(stdout, "[%s %s:%d] " format "\n",          \
                buffer, __FILE__, __LINE__, ##__VA_ARGS__); \
    } while (0)

#define ILOG(format, ...) LOG(INF, format, ##__VA_ARGS__)
#define DLOG(format, ...) LOG(BEBUG, format, ##__VA_ARGS__)
#define ELOG(format, ...) LOG(ERROR, format, ##__VA_ARGS__)

#endif